package com.xy.template.model;

import com.xy.template.constant.ColumnExcludeUtil;
import com.xy.template.constant.JavaNameUtil;

public class Attribute {
    private String camelName;
    private String pascalName;
    private String columnName;
    private String remarks;
    private String typeName;
    private int size;
    private PageAttribute ctrl;
    private int idx;

    public Attribute(String columnName, String typeName, String remarks, int size) {
        this.columnName = columnName;
        this.camelName = JavaNameUtil.toCamel(columnName);
        this.pascalName = JavaNameUtil.toPascal(columnName);
        this.remarks = remarks;
        this.typeName = typeName;
        this.size = size;

    }

    /**
     * 基础字段 非ID 比如创建和修改时间
     *
     * @return
     */
    public int getBusiItemType() {
        return ColumnExcludeUtil.isExt(columnName) ? 0 : 1;
    }

    /**
     * 基础字段，ID
     *
     * @return
     */
    public int getBusiItemType2() {
        return ColumnExcludeUtil.isExt2(columnName) ? 0 : 1;
    }

    public String getColumnName() {
        return columnName;
    }

    public void setColumnName(String columnName) {
        this.columnName = columnName;
    }

    public String getLabel() {
        if (remarks == null || remarks.trim().length() == 0) {
            return camelName;
        }
        return remarks;
    }

    public String getRemarks() {
        return remarks;
    }

    public void setRemarks(String remarks) {
        this.remarks = remarks;
    }

    public String getType() {
        return typeName;
    }

    public String getTypeName() {
        return typeName;
    }

    public void setTypeName(String typeName) {
        this.typeName = typeName;
    }

    public String getCamelName() {
        return camelName;
    }

    public void setCamelName(String camelName) {
        this.camelName = camelName;
    }

    public String getPascalName() {
        return pascalName;
    }

    public void setPascalName(String pascalName) {
        this.pascalName = pascalName;
    }

    public int getSize() {
        return size;
    }

    public void setSize(int size) {
        this.size = size;
    }

    public PageAttribute getCtrl() {
        return ctrl;
    }

    public void setCtrl(PageAttribute ctrl) {
        this.ctrl = ctrl;
    }

    public int getIdx() {
        return idx;
    }

    public void setIdx(int idx) {
        this.idx = idx;
    }
}
